{extend name="main_mobile"}
{block name="style"}
<style type="text/css">
	.flex-lable{width: 140px;color: #6c757d;text-align: right;padding-right: 10px;}
</style>
{/block}
{block name="body"}
<div class="bg-white mb-3 table-responsive p-3">
	<el-form :model="search" @submit.native.prevent="submitForm" ref="search"
	  label-position="right">

	  	<div class="flex flex-center">
		  	<div>
			  	<el-select v-model="search.search_type" placeholder="请选择" class="w-80px">
				    <el-option key="id"label="公司ID"value="id"></el-option>
				    <el-option key="uid"label="UID"value="uid"></el-option>
				    <el-option key="uscc"label="统一社会信用代码"value="uscc"></el-option>
				    <el-option key="company_name"label="公司名"value="company_name"></el-option>
				    <el-option key="contacts_mobile"label="联系人手机号"value="contacts_mobile"></el-option>
				    <el-option key="contacts_email"label="联系人邮箱"value="contacts_email"></el-option>
				</el-select>
		  	</div>
		  	<div class="mx-1 flex-1">
		    	<el-input v-model="search.key" placeholder="请输入你想搜索的关键词" clearable></el-input>
		  	</div>
		    <el-button type="primary" @click="sendHtml">查询</el-button>
		    <span class="text-nowrap px-2 py-3 small text-secondary"
		    @click="searchMore= !searchMore">{{searchMore?'收起':'更多'}}</span>
	  	</div>
	  	<div v-show="searchMore" style="display: none;" class="mt-3">

		  <el-form-item label="企业认证" prop="attestation">
		  	<el-select v-model="search.attestation" placeholder="请选择">
			    <el-option key="all"label="全部"value="all"></el-option>
			    <el-option v-for="v in attestation" :key="v.value":label="v.title":value="v.value"></el-option>
			</el-select>
		  </el-form-item>

		  <el-form-item label="套餐" prop="vip_level">
		  	<el-select v-model="search.vip_level" placeholder="请选择">
			    <el-option key="all"label="全部"value="all"></el-option>
			    <el-option v-for="v in vip" :key="v.level":label="v.title":value="v.level" v-if="v.is_company"></el-option>
			</el-select>
		  </el-form-item>
	  	</div>
	</el-form>
</div>

<div class="bg-white mb-2 p-3" v-for="(v,index) in tableData">
	<div class="flex flex-center">
	  	<div class="flex flex-center flex-1">
			<el-image
			  	v-if="v.headimg" 
			    style="width: 30px; height: 30px"
			    lazy
			    class="rounded-circle mr-2"
			    :src="v.headimg" 
			    :preview-src-list="[v.headimg]">
			</el-image>
	  		<div class="text-small">
		      	<div>{{v.nickname}}</div>
	      		<div>{{ v.uid }}</div>
	  		</div>
	  	</div>
	  	<div class="text-secondary text-small">ID:{{v.id}}</div>
	</div>
	<div class="flex pt-2">
		<div class="flex-1 flex flex-center">
			<div class="w-50px text-grey">企业</div>
			<div class="flex-1">
		      	<div>{{v.title}}</div>
		      	<div class="text-primary">{{v.mobile}}</div>
			</div>
		</div>
	</div>
	<div class="flex pt-2">
		<div class="flex-1 flex flex-center">
			<div class="w-80px text-grey">企业认证</div>
			<div class="flex-1">
		      	<transition>
		      		<el-button v-for="attestation in attestation" :type="attestation.type" size="minism"
		      		v-if="v.attestation==attestation.value"
		      		@click="window.open('/company/attestation?uid='+v.uid)">{{attestation.title}}</el-button>
				</transition>
			</div>
		</div>
		<div class="flex-1 flex flex-center">
			<div class="w-50px text-grey">名企</div>
			<div class="flex-1">
		      	<transition>
		      		<el-button type="success" size="minism"
		      		v-if="v.is_famous==1 || v.is_famous=='loading'"
		      		@click="setIsFamous(v);" 
		      		:loading="v.is_famous=='loading'">是</el-button>
		      		<el-button type="info" size="minism" 
		      		v-else-if="v.is_famous==0 || v.is_famous=='loading'" 
		      		@click="setIsFamous(v);" 
		      		:loading="v.is_famous=='loading'">否</el-button>
				</transition>
			</div>
		</div>
	</div>
	<div class="flex pt-2">
		<div class="flex-1 flex flex-center">
			<div class="w-50px text-grey">会员</div>
			<div class="flex-1">
		      		<div class="flex">
			      		<div>{{v.vip_title}}</div>
						<el-popover
						placement="top"
						width="326"
						trigger="click">
							<div class="pb-3">
								{{v.title}}
							</div>
							<div class="flex flex-center">
								<div class="flex-lable" style="width: 80px;">套餐</div>
								<el-select v-model="giveFormVip" placeholder="选择套餐" class="flex-1"
					      		size="small">
								    <el-option v-for="v in vip" :key="v.id" :label="v.title" :value="v.id" v-if="v.is_company"></el-option>
								</el-select>
							</div>
							<div class="flex flex-center mt-3">
								<div class="flex-lable" style="width: 80px;">额外天数</div>
					      		<el-input-number v-model="giveFormVipDay" :step="1" step-strictly
					      		:min="0"
					      		size="small"
					      		controls-position="right"
					      		class="flex-1"
					      		placeholder="额外天数"></el-input-number>
							</div>
							<div class="flex flex-center mt-3">
								<div class="flex-lable" style="width: 80px;">到期时间</div>
							    <el-date-picker
							      v-model="giveVipTime"
							      align="right"
							      type="date"
					      		  size="small"
							      format="yyyy-M-d"
							      value-format="yyyy-M-d"
							      placeholder="会员到期时间">
							    </el-date-picker>
							</div>
							<div class="bg-light p-2 rounded my-3 text-secondary small">
								<div>赠送套餐时间、权益将会累加</div>
								<div>如不修改会员到期时间<span class="text-danger">请勿选择</span></div>
							</div>
				      		<div class="flex">
				      			<div class="flex-1"></div>
							  		<el-button type="primary" size="mini"
							  		@click="giveCompanyVip(v)">修改</el-button>
							  	</div>
		      				<div class="ml-1 text-primary pointer" slot="reference">修改</div>
						</el-popover>
		      		</div>
			      	<div v-if="v.company_vip_time">{{v.company_vip_time}}</div>
			      	<div v-else>不限</div>
		      	</div>
		</div>
		<div class="flex-1 flex flex-center">
			<div class="w-50px text-grey">职位数</div>
			<div class="flex-1">
		      	<div><span class="text-danger">{{v.jobs_count}}</span>个</div>
		      	<el-link type="primary" :href="'/jobs/addJobs/'+v.id" :underline="false" target="_blank" v-if="v.attestation==3">添加</el-link>
			</div>
		</div>
	</div>
	<div class="flex pt-2">
		<div class="flex-1 flex flex-center">
			<div class="w-50px text-grey">刷新</div>
			<div class="flex-1">{{v.refresh_time}}</div>
		</div>
	</div>
	<div class="flex flex-center pt-3">
		<div class="flex-1 text-grey text-small">{{v.create_time}}通过{{v.app_name}}注册</div>
		<el-button round size="mini" @click="getCompanyInfo(v)">查看</el-button>
	</div>
</div>
<div class="table-responsive py-3 text-center">
	<el-pagination
	  background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="search.page"
      :page-sizes="[10,50,100,200]"
      :page-size="search.pageSize"
      layout="total, sizes, prev, next"
      :total="search.total">
    </el-pagination>
</div>
<el-dialog
  title="企业信息"
  :visible.sync="userDialogVisible"
  width="100%"
  top="0"
  :before-close="closeDrawerHandle"
  custom-class="mb-0">
	<div v-if="drawerHandleFind.id">
	  	<div v-if="drawerHandleFind.company_info==1">
		  	<div class="text-dark">
		  		<div>
					<el-divider content-position="left">用户信息</el-divider>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">用户</div>
						<el-image
						  	v-if="drawerHandleFind.data.headimg" 
						    style="width: 30px; height: 30px"
						    lazy
						    class="rounded-circle mr-2"
						    :src="drawerHandleFind.data.headimg" 
						    :preview-src-list="[drawerHandleFind.data.headimg]">
						</el-image>
		  				<div class="flex-1">
					      	<el-link :href="'/user?uid='+drawerHandleFind.uid" target="_blank"
					      	:underline="false"
					      	title="用户中心">{{drawerHandleFind.data.nickname}}</el-link>
		  				</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">手机号</div>
		  				<div class="flex-1">{{drawerHandleFind.data.mobile}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">邮箱</div>
		  				<div class="flex-1">{{drawerHandleFind.data.email}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3" v-if="(!drawerHandleFind.data.adviser_id&&v.adviser_default)||(drawerHandleFind.data.adviser_id&&v.id==drawerHandleFind.data.adviser_id)" v-for="v in admin">
		  				<div class="flex-lable">顾问</div>
						<el-image
						  	v-if="v.headimg" 
						    style="width: 30px; height: 30px"
						    lazy
						    class="rounded-circle mr-2"
						    :src="v.headimg" 
						    :preview-src-list="[v.headimg]">
						</el-image>
		  				<div class="flex-1">
					      	<el-link
					      	:underline="false">{{v.nickname}}</el-link>
		  				</div>
		  			</div>
					<el-divider content-position="left">企业基本信息</el-divider>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">ID</div>
		  				<div class="flex-1">{{drawerHandleFind.data.id}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">企业简称</div>
		  				<div class="flex-1">{{drawerHandleFind.data.stitle}}</div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">企业认证</div>
	      				<div class="flex-1">
				      		<el-button v-for="v in attestation" :type="v.type" size="minism"
				      		v-if="drawerHandleFind.data.attestation==v.value">{{v.title}}</el-button>
	      				</div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">营业执照</div>
	      				<div class="flex-1" >
						  <el-image
						  	v-if="drawerHandleFind.data.business_license" 
						  	class="mw-50px mh-50px"
						    :src="drawerHandleFind.data.business_license"
						    :preview-src-list="[drawerHandleFind.data.business_license]">
						  </el-image>
						  <div v-else class="text-secondary small">未上传</div>
	      				</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">统一社会信用代码</div>
	      				<div class="flex-1">{{drawerHandleFind.data.uscc}}</div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">企业LOGO</div>
	      				<div class="flex-1" >
						  <el-image
						  	v-if="drawerHandleFind.data.logo" 
						  	class="mw-50px mh-50px"
						    :src="drawerHandleFind.data.logo"
						    :preview-src-list="[drawerHandleFind.data.logo]">
						  </el-image>
						  <div v-else class="text-secondary small">未上传</div>
	      				</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">企业性质</div>
	      				<div class="flex-1" v-for="v in nature" v-if="drawerHandleFind.data.nature==v.value">{{v.title}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">融资阶段</div>
	      				<div class="flex-1" v-for="v in finance" v-if="drawerHandleFind.data.finance==v.value">{{v.title}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">所属行业</div>
	      				<div class="flex-1">{{drawerHandleFind.data.industry}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">公司规模</div>
	      				<div class="flex-1" v-for="v in size_type" v-if="drawerHandleFind.data.size_type==v.value">{{v.title}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">注册资金</div>
	      				<div class="flex-1">{{drawerHandleFind.data.registered_capital}}万{{drawerHandleFind.data.registered_capital?'人民币':'美元'}}</div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">企业福利</div>
	      				<div class="flex-1"><el-tag size="small" type="success" v-for="v in corporate_welfare" v-if="drawerHandleFind.data.corporate_welfare.indexOf(v.value)>=0" class="mr-2">{{v.title}}</el-tag></div>
		  			</div>
		  		</div>
		  		<div>
					<el-divider content-position="left">企业拓展信息</el-divider>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">企业联系人</div>
	      				<div class="flex-1">{{drawerHandleFind.data.contacts}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">联系人手机号</div>
	      				<div class="flex-1">{{drawerHandleFind.data.contacts_mobile}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">固定电话</div>
	      				<div class="flex-1">{{drawerHandleFind.data.contacts_tel}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">联系邮箱</div>
	      				<div class="flex-1">{{drawerHandleFind.data.contacts_email}}</div>
		  			</div>
		  			<div class="flex flex-center pb-3">
		  				<div class="flex-lable">公司地址</div>
	      				<div class="flex-1">{{drawerHandleFind.data.contacts_address}}</div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">公司网址</div>
	      				<div class="flex-1">{{drawerHandleFind.data.company_website}}</div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">公司简介</div>
	      				<div class="flex-1" v-html="XYBase.strntobr(drawerHandleFind.data.company_introduction)"></div>
		  			</div>
		  			<div class="flex pb-3">
		  				<div class="flex-lable">公司介绍</div>
	      				<div class="flex-1" v-html="XYBase.strntobr(drawerHandleFind.data.company_descript)"></div>
		  			</div>
		  		</div>
		  	</div>
	  	</div>
	  	<div class="text-center py-5 text-secondary small" v-else-if="drawerHandleFind.company_info==0">
	  		<i class="el-icon-loading mr-2"></i>加载中...
	  	</div>
	  	<div class="text-center py-5 text-secondary small" v-else="drawerHandleFind.company_info">
	  		未获取到用户信息
	  	</div>
	</div>
	<div slot="footer" class="table-responsive text-nowrap">
        <el-button
            type="primary"
            size="minism"
            @click="window.open('/company/editCompany/'+drawerHandleFind.id)">
            编辑
        </el-button>
	    <el-button
            size="minism"
            @click="closeDrawerHandle">关闭</el-button>
        <el-button
            type="success"
            size="minism"
            @click="window.open('/jobs/addJobs/'+drawerHandleFind.id)">
            发布职位
        </el-button>
        <el-button
            type="primary"
            size="minism"
            @click="userDialogVisible=false;drawerHandleFind=drawerHandleFind;drawerHandle=true;">
            设置顾问
        </el-button>
        <el-button
            type="info"
            size="minism"
            @click="window.open('/user/loginLog?uid='+drawerHandleFind.uid)">
            登录日志
        </el-button>
        <el-button
            type="info"
            size="minism"
            @click="window.open('/user/apiLog?uid='+drawerHandleFind.uid)">
            操作日志
        </el-button>
        <el-button
            type="info"
            size="minism"
            @click="window.open('{:config('web.url')}/company/'+drawerHandleFind.id+'.html')">
            浏览
        </el-button>
	</div>
</el-dialog>
<el-drawer
  title="我是标题"
  :visible.sync="drawerHandle"
  :with-header="false"
  :before-close="closeDrawerHandle"
  size="100%"
  top="0"
  custom-class="mb-0">
  	<div class="wrap h-100">
		<div class="flex px-3 py-2">
			<div class="flex-1 block-title-before py-2">设置顾问</div>
			<div class="py-2">
		  		<div class="small" v-if="drawerHandleFind.id">{{drawerHandleFind.title}}</div>
		  		<div class="small" v-else>批量设置</div>
			</div>
		</div>
		<div class="flex1 p-3" style="overflow-y: auto;">
			<div class="flex flex-center border border-lg rounded-lg mb-3 p-3 pointer"
			v-for="v in admin"
			:class="{'border-primary':adviser.id==v.id}"
			@click="adviser=v">
				<el-image
				  	v-if="v.headimg" 
				    style="width: 60px; height: 60px"
				    lazy
				    class="rounded-circle mr-2"
				    :src="v.headimg" 
				    :preview-src-list="[v.headimg]">
				</el-image>
  				<div class="flex-1">
			      	<el-link
			      	:underline="false">{{v.nickname}}</el-link>
  				</div>
  				<div class="text-secondary small" v-if="v.adviser_default">默认</div>
			</div>
		</div>
	  	<div class="flex px-3 py-2">
	  		<div class="flex-1">
			    <el-button @click="drawerHandle=false;drawerHandleFind={};">关闭</el-button>
		    </div>
	  		<div v-if="drawerHandleFind.id">
		    	<el-button type="primary" @click="setAdviser(drawerHandleFind)">设置</el-button>
		    </div>
	  		<div v-else>
		    	<el-button type="primary" @click="setAdviserALL()">设置</el-button>
		    </div>
	  	</div>
  	</div>
</el-drawer>
{/block}
{block name="script"}
<script type="text/javascript">
	{empty name="admin"}
	var admin=[];
	{else/}
	var admin={:json_encode($admin,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="attestation"}
	var attestation=[];
	{else/}
	var attestation={:json_encode($attestation,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="nature"}
	var nature=[];
	{else/}
	var nature={:json_encode($nature,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="finance"}
	var finance=[];
	{else/}
	var finance={:json_encode($finance,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="industry"}
	var industry=[];
	{else/}
	var industry={:json_encode($industry,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="size_type"}
	var size_type=[];
	{else/}
	var size_type={:json_encode($size_type,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="corporate_welfare"}
	var corporate_welfare=[];
	{else/}
	var corporate_welfare={:json_encode($corporate_welfare,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="vip"}
	var vip=[];
	{else/}
	var vip={:json_encode($vip,JSON_UNESCAPED_UNICODE)};
	{/empty}
</script>
<script type="text/javascript">
	var loading=null;
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			vip:vip,
			labelPosition:'right',
			searchMore:false,
			drawerHandle:false,
			userDialogVisible:false,
			drawerHandleFind:{},
			admin:admin,
			adviser:{id:0},
			attestation:attestation,
			nature:nature,
			finance:finance,
			industry:industry,
			size_type:size_type,
			corporate_welfare:corporate_welfare,
			multipleSelection:[],
			search:{
				{notempty name=":request()->get('uid')"}
				search_type:'uid',
				key:'{:request()->get('uid')}',
				{elseif request()->get('id')/}
				search_type:'id',
				key:'{:request()->get('id')}',
				{elseif request()->get('uscc')/}
				search_type:'uscc',
				key:'{:request()->get('uscc')}',
				{elseif request()->get('company_name')/}
				search_type:'company_name',
				key:'{:request()->get('company_name')}',
				{elseif request()->get('contacts_mobile')/}
				search_type:'contacts_mobile',
				key:'{:request()->get('contacts_mobile')}',
				{elseif request()->get('contacts_email')/}
				search_type:'contacts_email',
				key:'{:request()->get('contacts_email')}',
				{else/}
				search_type:'id',
				key:'',
				{/notempty}
				attestation:'all',
				vip_level:'all',
				ajax:false,
				page:1,
				total:0,
				pageSize:10
			},
			tableData:[],
			giveFormVip:'',
			giveVipTime:'',
			giveFormVipDay:0,
		},
		watch:{
		    view:XYBase.viewWatch,
		},
		created(){
			XYBase.created(this);
		},
	    methods: {
	    	giveCompanyVip(row){
	    		if(!this.giveFormVip&&!this.giveFormVipDay&&!this.giveVipTime)return XYBase.msg('请选择套餐，额外天数，会员到期时间');
	    		var vip_title='',title='';
	    		if(this.giveFormVip){
		    		for (var i = 0; i < this.vip.length; i++) {
		    			if(this.vip[i].id===this.giveFormVip){
		    				vip_title=this.vip[i].title;
		    				break;
		    			}
		    		}
		    		if(!vip_title)return XYBase.msg('请选择套餐');
	    		}
	    		if (vip_title&&this.giveFormVipDay) {
		    		title='确定将【'+vip_title+'】套餐和【'+this.giveFormVipDay+'天】额外会员天数赠送给【'+row.title+'】吗？';
	    		}else if (vip_title&&!this.giveFormVipDay){
		    		title='确定将【'+vip_title+'】套餐赠送给【'+row.title+'】吗？';
	    		}else if (!this.giveFormVip&&this.giveFormVipDay){
		    		title='确定赠送【'+this.giveFormVipDay+'天】额外会员天数给【'+row.title+'】吗？';
	    		}else if (!this.giveFormVip&&!this.giveFormVipDay&&this.giveVipTime){
		    		title='确定修改【'+row.title+'】的会员到期时间为【'+this.giveVipTime+'】吗？';
	    		}
	    		var _this=this;
		        this.$confirm(title, '提示', {
		        	dangerouslyUseHTMLString:true,
		          	confirmButtonText: '修改',
		          	cancelButtonText: '取消',
		          	type: 'warning'
		        }).then(() => {
					var loadinger = XYBase.openloading();
					$.ajax({
						url:'/company/giveCompanyVip',
						type:'post',
						data:{
							id:this.giveFormVip,
							day:this.giveFormVipDay,
							time:this.giveVipTime,
							uid:row.uid
						},
						dataType:'json',
						error:function(err){
							this.giveFormVip='';
					        loadinger.close();
				          	XYBase.error(XYBase.config.system_network_error);
						},
						success:function(ret){
							this.giveFormVip='';
					        loadinger.close();
							if (ret) {
								if (ret.code === 0) {
									if (ret.data.vip_title)
									row.vip_title=ret.data.vip_title;
									row.company_vip_time=ret.data.company_vip_time;
									_this.giveVipTime='';
									XYBase.success(ret.msg);
								}else XYBase.msg(ret.msg);
							}else XYBase.error(XYBase.config.system_network_error);
						}
					})
		        }).catch(() => {
					XYBase.msg('已取消');
		        });
	    	},
	    	closeDrawerHandle(done){
	    		this.drawerHandleFind={};
	    		typeof done=='function'?done():'';
	    	},
		    toggleSelection(rows) {
		        if (rows) {
		          rows.forEach(row => {
		            this.$refs.tableList.toggleRowSelection(row);
		          });
		        } else {
		          this.$refs.tableList.clearSelection();
		        }
		    },
		    handleSelectionChange(val) {
		        this.multipleSelection = val;
		    },
			resetForm:function(formName) {
				this.$refs[formName].resetFields();
			},
			handleSizeChange(val) {
				this.search.page=1;
				this.search.pageSize=val;
	          	this.initHtml();
			},
			handleCurrentChange(val) {
				this.search.page=val;
	          	this.initHtml();
			},
			setIsFamous(data){
	    		if (data.is_famous=='loading') return;
	    		var is_famous=1,oldStatus=data.is_famous;
	    		if (data.is_famous) is_famous=0;
	    		data.is_famous='loading';
	    		$.getJSON('/company/setIsFamous/'+data.id+'/'+is_famous,function(ret){
	    			data.is_famous=oldStatus;
	    			if (ret) {
	    				if (ret.code === 0) {
	    					data.is_famous=is_famous;
	    				}else{
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
			},
    	setCompanyDelete(val,index){
    		var _this=this;
	        _this.$confirm('确定将《'+val.title+'》放入回收站吗？', '提示', {
	          confirmButtonText: '确定',
	          cancelButtonText: '取消',
	          type: 'warning'
	        }).then(() => {
	    		$.getJSON('/company/setCompanyDelete/'+val.id,function(ret){
	    			if (ret) {
	    				if (ret.code === 0) {
	    					_this.tableData.splice(index,1);
	    				}else{
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
	        }).catch(() => {
  				XYBase.msg('已取消');
	        });
    	},
			setAdviser(row){
				var _this=this;
				if(!_this.adviser.id) return XYBase.msg('请先选择顾问');
				_this.drawerHandle=false;
				var loadinger = XYBase.openloading();
				$.ajax({
					url:'/company/setAdviser/'+row.id+'/'+_this.adviser.id,
					type:'get',
					data:{},
					dataType:'json',
					error:function(err){
				        loadinger.close();
			          	XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
				        loadinger.close();
						if (ret) {
							if (ret.code === 0) {
								row.data.adviser_id=_this.adviser.id;
								XYBase.success(ret.msg);
							}else XYBase.msg(ret.msg);
						}else XYBase.error(XYBase.config.system_network_error);
					}
				})
			},
			setAdviserALL(){
				var _this=this;
				if(!_this.adviser.id) return XYBase.msg('请先选择顾问');
				if (_this.multipleSelection.length<1)return;
				_this.drawerHandle=false;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.setAdviserALLAjax();
			},
			setAdviserALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
						url:'/company/setAdviser/'+D.id+'/'+_this.adviser.id,
						type:'get',
						data:{},
						dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].data.adviser_id=_this.adviser.id;
									_this.multipleSelectionIndex++;
									_this.setAdviserALLAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.setAdviserALLAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
			refreshCompanyALL(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.refreshCompanyALLAjax();
			},
			refreshCompanyALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
						url:'/company/refreshCompany/'+D.id,
						type:'get',
						dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].refresh_time=ret.data.refresh_time;
									_this.multipleSelectionIndex++;
									_this.refreshCompanyALLAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.refreshCompanyALLAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
			getCompanyInfo(row) {
				var _this=this;
				this.drawerHandleFind=row;
				if (row.company_info)return _this.userDialogVisible=true;
	    		$.getJSON('/getCompanyInfo/'+row.id,function(ret){
	    			if (ret) {
	    				_this.userDialogVisible=true;
	    				if (ret.code === 0) {
	    					row.company_info=1;
	    					row.data=ret.data;
	    				}else{
	    					row.company_info=2;
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
			},
			sendHtml(){
				this.search.page=1;
				this.initHtml();
			},
	    initHtml() {
	    	var _this=this;
	    	_this.search.ajax=true;
				$.ajax({
					url:'',
					type:'get',
					data:_this.search,
					dataType:'json',
					error:function(err){
	      				_this.search.ajax=false;
						XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
	      				_this.search.ajax=false;
						if (ret) {
							if (ret.code === 0) {
								_this.search.total=ret.data.total;
								_this.tableData=ret.data.data;
							}else{
								XYBase.msg(ret.msg);
							}
						}else{
							XYBase.error(XYBase.config.system_network_error);
						}
					}
				});
			},
	    exportCompany() {
	    	var _this=this;
	    	_this.search.ajax=true;
	    	var loading=XYBase.openloading();
				$.ajax({
					url:'/company/exportCompany',
					type:'get',
					data:_this.search,
					dataType:'json',
					error:function(err){
	      		_this.search.ajax=false;
	      		loading.close();
						XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
	      		loading.close();
	      		_this.search.ajax=false;
						if (ret) {
							if (ret.code === 0) {
								window.open(ret.data.url);
							}else{
								XYBase.msg(ret.msg);
							}
						}else{
							XYBase.error(XYBase.config.system_network_error);
						}
					}
				});
			}
	    }
	});
	$(function(){
		vm.initHtml();
		reloadWindowSize();
		$(window).resize(function(){
			reloadWindowSize();
		});
	});
	function reloadWindowSize (argument) {
		var winW=$(window).width();
		if(winW <= 576){
			vm.labelPosition='top';
		}else{
			vm.labelPosition='right';
		}
	}
</script>
{include file="business"/}
{/block}